/*
 * HTMLLexer.h
 *
 *  Created on: 2010-5-2
 *      Author: Guobc
 */

#ifndef HTMLLEXER_H_
#define HTMLLEXER_H_

#include <fstream>
#include <string>
#include <memory>
#include <cctype>
#include "URL.h"
#include "URLConnection.h"
#include "Lexer.h"
#include "Token.h"

namespace HA {

class HTMLLexer: public HA::Lexer {
public:

	/**
	 * construct method
	 * @param name HTML file name
	 * */
	HTMLLexer(string buffer);

	/*
	 * Return next token.
	 *
	 * @return A token.
	 * */
	inline Token* nextToken() throw (ParserException) {
		return fetchToken();
	}

//	/**
//	 * Set document to lexer
//	 * @param document.
//	 */
//	inline void setDocument(ASTDom* document) {
//		mDocument = document;
//	}
//
//	/**
//	 * Get document of this lexer.
//	 * @return
//	 */
//	inline ASTDom* getDocument() {
//		return mDocument;
//	}
//
//	/**
//	 * Open this lexer input stream.
//	 * @return True if success, false otherwise.
//	 */
//	bool open();
//
//	/**
//	 * Test whether input stream is open.
//	 * @return True is open, false otherwise.
//	 */
//	inline bool isOpen() {
//		return fin.is_open();
//	}
//
//	/**
//	 * close this lexer input stream.
//	 * @return True if success, false otherwise.
//	 */
//	void close();

	/**
	 * Get the position from the input character stream.
	 * @return
	 */
	int getPosition();

	/**
	 * Get the line number from the input character stream.
	 * return
	 */
	inline int getLineNumber() {
		return m_line;
	}

//	inline void clear() {
//		m_buffer.clear();
//	}

protected:

	/**
	 * Fetch a token from character stream.
	 * @return A token.
	 */
	Token* fetchToken() throw (ParserException);

private:

	Token* newToken(string line, int type);

private:
	int m_line;
	string::size_type m_offset;
};

}

#endif /* HTMLLEXER_H_ */
